pro contour3,data,x,y,level=level,xrange=xrange,yrange=yrange,zrange=zrange,$
    xtitle=xtitle,ytitle=ytitle,title=title,chars=chars,thick=thick    
     
    IF NOT KEYWORD_SET(level) THEN level=10
    IF NOT KEYWORD_SET(xtitle) THEN xtitle="X"
    IF NOT KEYWORD_SET(ytitle) THEN ytitle="Y"
    IF NOT KEYWORD_SET(title) THEN ytitle=""
    
    IF NOT KEYWORD_SET(chars) THEN chars=1
    IF NOT KEYWORD_SET(thick) THEN thick=1
    
    ; number of parameters used
    np = N_PARAMS()
    dim = SIZE(data, /dim)

    IF np LT 3 THEN y = FINDGEN(dim[1])
    IF np LT 2 THEN x = FINDGEN(dim[0]) 
   
    ; get data range
    if not keyword_set(zrange)then  zrange=1.0*[min(data),max(data)]
    if not keyword_set(xrange)then  xrange=1.0*[min(x),max(x)]
    if not keyword_set(yrange)then  yrange=1.0*[min(y),max(y)]
     
    ;cgDisplay, WID=0
    
    ;test unit
    ;data = cgScaleVector(cgDemoData(2), 0.1, 4534.5)
    ncolors=level
    cgLoadCT, 33, NColors=ncolors,bottom=1

    ;levels = cgConLevels(data, Factor=100, MINVALUE=0)
    ;cgContour, data, Levels=levels, /Fill, /Outline, $
    ;   Position=[0.1, 0.1, 0.9, 0.75], C_Colors=Indgen(10)+1


    ;/outline -> label
    ;bottom=1 -> avoiding hole		
    cgContour, data,x,y,xtitle=xtitle,ytitle=ytitle, NLevels=ncolors,/Fill,/xst,/yst,xrange=xrange,yrange=yrange, $
      Position=[0.1, 0.1, 0.8, 0.93], C_Colors=Indgen(ncolors)+1,chars=chars,charthick=thick
    ;/FIT -> not work well with charsize keyword
    ;Default is[0.88, 0.10, 0.95, 0.90] for a vertical bar and [0.10, 0.88, 0.90, 0.95] for a horizontal bar
    ;cgColorBar,NColors=ncolors,Divisions=4, Minor=5, Format='(F0.2)',/zst,Range=zrange,title=title,/bottom,$
    ;   Position=[0.1,0.85,0.9,0.93],charsize=chars,textthick=thick
    cgColorBar,NColors=ncolors,Divisions=4, Minor=5, Format='(E0.2)',/zst,Range=zrange,title=title,/Vertical,$
      Position=[0.82,0.10,0.88,0.93],/right,charsize=chars,textthick=thick

    print, ' zrange min ',min(1.0*zrange),'max',max(1.0*zrange)
    print, ' xrange min ',min(1.0*xrange),'max',max(1.0*xrange)
    print, ' yrange min ',min(1.0*yrange),'max',max(1.0*yrange)
end
